<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let arr = [2, 0, 6, 0, 18, 0, 15, 40]
        arr.reverse()
        console.log(arr);
        let k = []
        let ars = [40, 15, 0, 18, 0, 6, 0, 2]
        for(i=0;i<ars.length;i++){
            k.unshift(ars[i])
        }console.log(k);
        
    </script>
</body>
</html>